package org.mags.rema.model.provider;

// Generated Dec 6, 2009 5:47:57 PM by Hibernate Tools 3.2.2.GA
// powered by BTS-GT

import java.util.Collection;

import org.mags.dao.common.EntityProperties;
import org.mags.dao.common.Limits;
import org.mags.dao.common.SOrder;
import org.mags.dao.common.RestrictionBuilder;
import org.mags.dao.provider.AbstractNoCacheableDataProvider;
import org.mags.rema.model.entity.Entity;

public class EntityProvider extends AbstractNoCacheableDataProvider<Entity> {
	private static final long serialVersionUID = 1L;
	private EntityTypeProvider entityTypeProvider;
	
	public Collection<Entity> getByRestriction(EntityProperties entityProperties, RestrictionBuilder restriction, SOrder[] orderBy, Limits limits) {
		return super.getByRestriction(entityProperties, restriction, orderBy, limits);
	}
	public EntityProvider(EntityTypeProvider entityTypeProvider) {
		this.entityTypeProvider = entityTypeProvider;
	}
	public EntityTypeProvider getEntityTypeProvider() {
		return entityTypeProvider;
	}
	public void setEntityTypeProvider(EntityTypeProvider entityTypeProvider) {
		this.entityTypeProvider = entityTypeProvider;
	}
	protected void loadProperties(Entity one) {
		one.setEntityType(entityTypeProvider.getById(one.getEntityType().getEntityTypeId()));
	}
	protected void loadProperties(Entity[] many) {
		for(Entity i: many) 
			this.loadProperties(i);
	}	
}
